<ul class=headsup_panel>
	<li class=col1>
		<h1>search the universe</h1>
	</li>
	<li class='col2 right'>
		<form action="<?php echo $this->base ?>/subjects/search/" method="post">
			<select name="search_type" class="search_type">
				<option value="0">Subjects</option>
				<option value="1">Tags</option>
			</select>
			<input type="search" name="subject" placeholder="Type Keyword">
			<button type="submit"> &nbsp; </button>
		</form>
	</li>
</ul>

<div class=listing_panel>
	
	<ul class=lp_search_info>
		<li class='breadings col1'>
			<ul>
				<li>Search</li>
				<li> &#9002; </li>
				<li><?php echo $keyword; ?></li>
			</ul>
		</li>
		<li class='pagination col2 right'>
            <!-- Shows the page numbers -->
            <?php echo $this->Paginator->numbers( array(
                'separator' => '&nbsp;',                
                'modulus' => 4,
                'first' => 1,
                'last' => 1
            )); ?>
            <!-- prints X of Y, where X is current page and Y is number of pages -->
            <?php echo $this->Paginator->counter(); ?>
		</li>
	</ul>
	
	<table>
		<tbody>
            <?php 
            $total = count($data);
            if($total > 0)
            {
            ?>
			<tr>
            <?php
                if($total <= 10)
                    $limit = $total;
                else
                    $limit = 10;
                for ($i = 0; $i < $limit; $i++) {
                $subject = $data[$i];
                $thumbnail = $this->PhpThumb->generate(
                                        array(
                                            'save_path' => WWW_ROOT . 'img/uploads/Subjects/thumbs',
                                            // Where to save the thumbnail. (Make sure it is writable by the web server)
        
                                            'display_path' => 'uploads/Subjects/thumbs',
                                            // The web accessible path to the directory that the thumbnail lives in after its created.
        
                                            'error_image_path' => 'img/error.jpg',
                                            // The default image to display if something goes wrong while generating a thumbnail. 
        
                                            'src' => WWW_ROOT . "img/uploads/Subjects/" . $subject['Subject']['image'],
                                            // The source image to be converted into a thumbnail.
                                            // From here on out, you can pass any standard phpThumb parameters
        
                                            'w' => 100,
                                            'h' => 130,
                                            'q' => 100,
                                            'zc' => 1
                                            //'fltr'=>array('ric|4|4')
                                        )
                                );
                $strSubjDis = $subject['Subject']['subject'];
                if(strlen($strSubjDis) > 10)
                {
                    $strSubjDis = substr($strSubjDis, 0, 9) . '...';
                }
                ?>
				<td>
                    <a href="<?php echo $this->base ?>/subjects/subject/<?php echo $subject['Subject']['id'] ?>">
                    <?php echo $this->Html->image($thumbnail['src'], array('width' => $thumbnail['w'], 'height' => $thumbnail['h'],'title'=>$subject['Subject']['subject'],'alt'=>$subject['Subject']['subject'])); ?> <span><?php echo $strSubjDis ?></span>
                    </a>
                </td>
            <?php } ?>
			</tr>
            <?php
            }
            if($total >= 11)
            {
            ?>
			<tr>
            <?php
                if($total <= 20)
                    $limit = $total;
                else
                    $limit = 20;
                for ($i = 10; $i < $limit; $i++) {
                $subject = $data[$i];
                $thumbnail = $this->PhpThumb->generate(
                                        array(
                                            'save_path' => WWW_ROOT . 'img/uploads/Subjects/thumbs',
                                            // Where to save the thumbnail. (Make sure it is writable by the web server)
        
                                            'display_path' => 'uploads/Subjects/thumbs',
                                            // The web accessible path to the directory that the thumbnail lives in after its created.
        
                                            'error_image_path' => 'img/error.jpg',
                                            // The default image to display if something goes wrong while generating a thumbnail. 
        
                                            'src' => WWW_ROOT . "img/uploads/Subjects/" . $subject['Subject']['image'],
                                            // The source image to be converted into a thumbnail.
                                            // From here on out, you can pass any standard phpThumb parameters
        
                                            'w' => 100,
                                            'h' => 130,
                                            'q' => 100,
                                            'zc' => 1
                                            //'fltr'=>array('ric|4|4')
                                        )
                                );
                $strSubjDis = $subject['Subject']['subject'];
                if(strlen($strSubjDis) > 10)
                {
                    $strSubjDis = substr($strSubjDis, 0, 9) . '...';
                }
                ?>
				<td>
                    <a href="<?php echo $this->base ?>/subjects/subject/<?php echo $subject['Subject']['id'] ?>">
                    <?php echo $this->Html->image($thumbnail['src'], array('width' => $thumbnail['w'], 'height' => $thumbnail['h'],'title'=>$subject['Subject']['subject'],'alt'=>$subject['Subject']['subject'])); ?> <span><?php echo $strSubjDis ?></span>
                    </a>
                </td>
            <?php } ?>
			</tr>
            <?php
            }
            if($total >= 21)
            {
            ?>
			<tr>
            <?php
                if($total <= 30)
                    $limit = $total;
                else
                    $limit = 30;
                for ($i = 20; $i < $limit; $i++) {
                $subject = $data[$i];
                $thumbnail = $this->PhpThumb->generate(
                                        array(
                                            'save_path' => WWW_ROOT . 'img/uploads/Subjects/thumbs',
                                            // Where to save the thumbnail. (Make sure it is writable by the web server)
        
                                            'display_path' => 'uploads/Subjects/thumbs',
                                            // The web accessible path to the directory that the thumbnail lives in after its created.
        
                                            'error_image_path' => 'img/error.jpg',
                                            // The default image to display if something goes wrong while generating a thumbnail. 
        
                                            'src' => WWW_ROOT . "img/uploads/Subjects/" . $subject['Subject']['image'],
                                            // The source image to be converted into a thumbnail.
                                            // From here on out, you can pass any standard phpThumb parameters
        
                                            'w' => 100,
                                            'h' => 130,
                                            'q' => 100,
                                            'zc' => 1
                                            //'fltr'=>array('ric|4|4')
                                        )
                                );
                $strSubjDis = $subject['Subject']['subject'];
                if(strlen($strSubjDis) > 10)
                {
                    $strSubjDis = substr($strSubjDis, 0, 9) . '...';
                }
                ?>
				<td>
                    <a href="<?php echo $this->base ?>/subjects/subject/<?php echo $subject['Subject']['id'] ?>">
                    <?php echo $this->Html->image($thumbnail['src'], array('width' => $thumbnail['w'], 'height' => $thumbnail['h'],'title'=>$subject['Subject']['subject'],'alt'=>$subject['Subject']['subject'])); ?> <span><?php echo $strSubjDis ?></span>
                    </a>
                </td>
            <?php } ?>
			</tr>
            <?php
            }
            ?>
		</tbody>
	</table>

	<ul class=lp_search_info>
		<li class='breadings col1'></li>
		<li class='pagination col2 right'>
            <!-- Shows the page numbers -->
            <?php echo $this->Paginator->numbers( array(
                'separator' => '&nbsp;',
                'modulus' => 4,
                'first' => 1,
                'last' => 1
            )); ?>
            <!-- prints X of Y, where X is current page and Y is number of pages -->
            <?php echo $this->Paginator->counter(); ?>
		</li>
	</ul>

</div>